package com.steven.springbootrabbitmq.consumer;

import com.steven.springbootrabbitmq.config.ConfirmConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author liuxiangyu
 * @date 2021-07-07 22:52
 */
@Slf4j
@Component
public class WarningConsumer {
    //接收报警消息
    @RabbitListener(queues = ConfirmConfig.WARNING_QUEUE_NAME)
    public void receiveWarningMsg(Message message) {
        String msg = new String(message.getBody());
        log.info("当前时间：{}，接收到不可路由的报警消息：{}", new Date().toString(), msg);
    }
}
